package com.efamily.ewallet.client.account;

import com.extjs.gxt.ui.client.Style.LayoutRegion;
import com.extjs.gxt.ui.client.event.BaseEvent;
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.widget.Composite;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.layout.BorderLayout;
import com.extjs.gxt.ui.client.widget.layout.BorderLayoutData;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;

public class AccountsWidget extends Composite {
	private ContentPanel mainPanel = new ContentPanel();
	private ContentPanel centerPanel = new ContentPanel();
	private ContentPanel eastPanel = new ContentPanel();

	public AccountsWidget() {
		mainPanel.setHeaderVisible(false);
		final BorderLayout borderLayout = new BorderLayout();
		mainPanel.setLayout(borderLayout);
		eastPanel.addListener(Events.Render, new Listener<BaseEvent>(){
			public void handleEvent(BaseEvent be) {
				borderLayout.show(LayoutRegion.EAST);
				borderLayout.collapse(LayoutRegion.EAST);
			}
		});
		initComponent(mainPanel);
		addCenterPanel();
		//addEastPanel();

	}

	private void addEastPanel() {
		BorderLayoutData eastPanelData = new BorderLayoutData(LayoutRegion.EAST);
		eastPanelData.setCollapsible(true);
		eastPanelData.setSize(400);
		eastPanelData.setMaxSize(800);
		eastPanel.add(new AccountDetailsPanelWidget());
		eastPanel.setLayout(new FitLayout());
		eastPanelData.setSplit(true);
		mainPanel.add(eastPanel, eastPanelData);

	}

	

	private void addCenterPanel() {
		BorderLayoutData centerPanelData = new BorderLayoutData(
				LayoutRegion.CENTER);
		centerPanel.add(new PublicAccountGridWidget());
		centerPanel.setHeaderVisible(false);
		centerPanel.setLayout(new FitLayout());
		centerPanelData.setSplit(true);
		mainPanel.add(centerPanel, centerPanelData);
	}

}
